using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

public class StatusToColorConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        string status = value as string;
        if (string.IsNullOrEmpty(status))
            return Brushes.Black;

        if (status.StartsWith("成功"))
            return Brushes.Green;
        else if (status.StartsWith("错误") || status.StartsWith("失败"))
            return Brushes.Red;
        else
            return Brushes.Black;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}